<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
var arr1 = new Array(1,2,3);
var arr2 = new Array(1,1,1);

	//alert(arr1.length);
	Array.prototype.sum=function()   //类似于css 的class
	//arr1.sum = function()       //相当于行间样式
	{
		var result = 0;
		//alert(this.length);
		for(var i =0 ; i < this.length; i++)
			{
				 result+=this[i];
			}
	 return result;
	};
	
	alert(arr1.sum());
	alert(arr2.sum());
	
</script>
</head>

<body>
</body>
</html>
